module.exports = {
  apps: [
    // API服务
    {
      name: 'live-platform-api',
      script: 'dist/server/main.js',
      instances: 'max',
      exec_mode: 'cluster',
      env: {
        NODE_ENV: 'production',
        PORT: 3000,

        // 数据库配置
        DB_HOST: 'localhost',
        DB_PORT: 3306,
        DB_USER: 'root',
        DB_PASSWORD: 'your_password',
        DB_NAME: 'live_platform',

        // Redis配置
        REDIS_HOST: 'localhost',
        REDIS_PORT: 6379,
        REDIS_PASSWORD: '',

        // 文件路径配置(Windows)
        UPLOAD_PATH: 'C:/live-platform/uploads',
        LOG_PATH: 'C:/live-platform/logs',
        STREAM_PATH: 'C:/live-platform/streams',

        // 邮件配置
        MAIL_HOST: 'smtp.qq.com',
        MAIL_PORT: 465,
        MAIL_USER: 'your_email@qq.com',
        MAIL_PASS: 'your_smtp_password',

        // 告警通知
        ALERT_EMAIL: 'admin@example.com',
        DINGTALK_WEBHOOK: '',
        DINGTALK_SECRET: '',
        WECHAT_WEBHOOK: '',
      },
      error_file: 'C:/live-platform/logs/pm2/api-error.log',
      out_file: 'C:/live-platform/logs/pm2/api-out.log',
      time: true,
    },

    // 流媒体服务
    {
      name: 'live-platform-stream',
      script: 'dist/server/stream.js',
      instances: 1,
      env: {
        NODE_ENV: 'production',
        STREAM_PORT: 8000,
        RTMP_PORT: 1935,
        HLS_PORT: 8080,
      },
      error_file: 'C:/live-platform/logs/pm2/stream-error.log',
      out_file: 'C:/live-platform/logs/pm2/stream-out.log',
      time: true,
    },

    // 定时任务
    {
      name: 'live-platform-cron',
      script: 'dist/server/cron.js',
      instances: 1,
      env: {
        NODE_ENV: 'production',
      },
      error_file: 'C:/live-platform/logs/pm2/cron-error.log',
      out_file: 'C:/live-platform/logs/pm2/cron-out.log',
      time: true,
    },
  ],
}
